VERSION 5.00
Begin VB.Form frmEmailExtract 
   Caption         =   "Form1"
   ClientHeight    =   3090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3090
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
   Begin VB.ListBox lstActivities 
      Height          =   1425
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   4335
   End
End
Attribute VB_Name = "frmEmailExtract"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Form_Activate()
    
Dim i As Integer
Dim lngResult As Long
Dim File1 As Scripting.File
Dim File2 As Scripting.File
Dim File3 As Scripting.File
Dim File4 As Scripting.File
Dim File5 As Scripting.File
Dim File6 As Scripting.File
Dim blGetFiles As Boolean
Dim j As String

Dim clsGetFiles As clsGetFiles
Set clsGetFiles = New clsGetFiles

'Extracting Form A&D from database
i = 0
lstActivities.AddItem "Checking database for new Form A&D requests . . . ", i
Dim objExtractAD As Object
Set objExtractAD = CreateObject("KtExtractAD.clsExtractAD")
lngResult = objExtractAD.Extract
Set objExtractAD = Nothing
lstActivities.RemoveItem i
If lngResult >= 0 Then
    lstActivities.AddItem "Checking database for new Form A&D requests . . . " & lngResult & " record(s) extracted", i
Else
    lstActivities.AddItem "Checking database for new Form A&D requests . . . Error " & lngResult, i
End If
lstActivities.Refresh

'Extracting Form B from database
i = 1
lstActivities.AddItem "Checking database for new Form B requests . . . ", i
Dim objExtractB As Object
Set objExtractB = CreateObject("KtExtractB.clsExtractB")
lngResult = objExtractB.Extract
Set objExtractB = Nothing
lstActivities.RemoveItem i
If lngResult >= 0 Then
    lstActivities.AddItem "Checking database for new Form B requests . . . " & lngResult & " record(s) extracted", i
Else
    lstActivities.AddItem "Checking database for new Form B requests . . . Error " & lngResult, i
End If
lstActivities.Refresh


'Extracting Form C from database
i = 2
lstActivities.AddItem "Checking database for new Form C requests . . . ", i
Dim objExtractC As Object
Set objExtractC = CreateObject("KtExtractC.clsExtract")
lngResult = objExtractC.Extract
Set objExtractC = Nothing
lstActivities.RemoveItem i
If lngResult >= 0 Then
    lstActivities.AddItem "Checking database for new Form C requests . . . " & lngResult & " record(s) extracted", i
Else
    lstActivities.AddItem "Checking database for new Form C requests . . . Error " & lngResult, i
End If
lstActivities.Refresh


'Extracting IRP3A from database
i = 3
lstActivities.AddItem "Checking database for new IRP3A requests . . . ", i
Dim objExtractIRP3A As Object
Set objExtractIRP3A = CreateObject("KTExtractIRP3A.clsExtractIRP3A")
lngResult = objExtractIRP3A.Extract
Set objExtractIRP3A = Nothing
lstActivities.RemoveItem i
If lngResult >= 0 Then
    lstActivities.AddItem "Checking database for new IRP3A requests . . . " & lngResult & " record(s) extracted", i
Else
    lstActivities.AddItem "Checking database for new IRP3A requests . . . Error " & lngResult, i
End If
lstActivities.Refresh

'Extracting IRP3B from database
i = 4
lstActivities.AddItem "Checking database for new IRP3B requests . . . ", i
Dim objExtractIRP3B As Object
Set objExtractIRP3B = CreateObject("KTExtractIRP3B.clsExtractIRP3B")
lngResult = objExtractIRP3B.Extract
Set objExtractIRP3B = Nothing
lstActivities.RemoveItem i
If lngResult >= 0 Then
    lstActivities.AddItem "Checking database for new IRP3B requests . . . " & lngResult & " record(s) extracted", i
Else
    lstActivities.AddItem "Checking database for new IRP3B requests . . . Error " & lngResult, i
End If
lstActivities.Refresh

'Extracting IRP3C from database
i = 5
lstActivities.AddItem "Checking database for new IRP3C requests . . . ", i
Dim objExtractIRP3C As Object
Set objExtractIRP3C = CreateObject("KTExtractIRP3C.clsExtractIRP3C")
lngResult = objExtractIRP3C.Extract
Set objExtractIRP3C = Nothing
lstActivities.RemoveItem i
If lngResult >= 0 Then
    lstActivities.AddItem "Checking database for new IRP3C requests . . . " & lngResult & " record(s) extracted", i
Else
    lstActivities.AddItem "Checking database for new IRP3C requests . . . Error " & lngResult, i
End If
lstActivities.Refresh

'Extracting Cancellations from database
i = 6
lstActivities.AddItem "Checking database for new Cancellations . . . ", i
Dim objExtractCan As Object
Set objExtractCan = CreateObject("KtExtractCancel.clsExtractCancel")
lngResult = objExtractCan.Extract
Set objExtractCan = Nothing
lstActivities.RemoveItem i
If lngResult >= 0 Then
    lstActivities.AddItem "Checking database for new Cancellations . . . " & lngResult & " record(s) extracted", i
Else
    lstActivities.AddItem "Checking database for new Cancellations . . . Error " & lngResult, i
End If
lstActivities.Refresh

'Get extract files from C:\Data\IS\Extracted
blGetFiles = clsGetFiles.GetFiles(File1, File2, File3, File4, File5, File6, j)

'SEND EMAIL WITH ATTACHMENTS
If blGetFiles = True Then
    frmEmailExtract.lstActivities.AddItem "Transferring files to email . . . "
    frmEmailExtract.lstActivities.Refresh
    Dim objclsEmailExtract As clsEmailExtract
    Set objclsEmailExtract = New clsEmailExtract
    Call objclsEmailExtract.EmailExtract(File1, File2, File3, File4, File5, File6)
    Set objclsEmailExtract = Nothing
    If j >= 0 Then
        frmEmailExtract.lstActivities.AddItem "Transferring files to email . . . Done" & j & " record(s) extracted"
    Else
        frmEmailExtract.lstActivities.AddItem "Transferring files to email . . . Error" & j
    End If
    frmEmailExtract.lstActivities.Refresh
End If

Unload frmEmailExtract

End Sub

Private Sub Form_Resize()
    lstActivities.Top = 0
    lstActivities.Width = frmEmailExtract.Width
    lstActivities.Height = frmEmailExtract.Width
End Sub

